﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BaseBL.Repository;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace Northwinddemo.Web.Tests.Repository
{
    abstract class FakeNorthwindRepository<T> : IRepository<T> where T : EntityBase2, IEntity2, new()
    {
        protected T[] entities;

        protected FakeNorthwindRepository(T entity)
        {
            this.entities = new T[] { entity };
        }

        protected FakeNorthwindRepository(T[] entities)
        {
            this.entities = entities;
        }
        
        public T GetById(int id)
        {
            return GetById(id, null);
        }

        public abstract T GetById(int id, IDataAccessAdapter adapter);

        public IList<T> GetAll()
        {
            return GetAll(null);
        }

        public abstract IList<T> GetAll(IDataAccessAdapter adapter);

        public void Save(T entity)
        {
            Save(entity, null);
        }

        public void Save(T entity, IDataAccessAdapter adapter)
        {
            entity.ValidateEntity(); // Run the validation of rules.
            // Do not actually save anything.
        }

        public void Delete(T entity)
        {
            Delete(entity, null);
        }

        public void Delete(T entity, IDataAccessAdapter adapter)
        {
            // Do not actually delete anything.
        }

    }
}
